package backend.service.admin;

import backend.model.admin.ForeignManager;
import backend.service.base.DBModelServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ForeignManagerServiceImpl extends DBModelServiceImpl<ForeignManager> implements ForeignManagerService {
    @Override
    public List<ForeignManager> findAllForeignManagers() {
        return dbModelDao.findByNamedQuery("findAllForeignManagers");
    }

    @Override
    public List<ForeignManager> findAllActiveForeignManagers() {
        return dbModelDao.findByNamedQuery("findAllActiveForeignManagers");
    }

    @Override
    public ForeignManager findForeignManagerByFirstAndLastName(String firstName, String lastName) {
        List<ForeignManager> managers = dbModelDao.findByNamedQueryAndParams("findForeignManagerByFirstAndLastName",
                new String[] {"firstName", "lastName"}, new Object[] {firstName, lastName});
        assert managers.size() <= 1;
        if (managers.size() == 1) {
            return managers.get(0);
        }
        return null;
    }

    @Override
    public Class<ForeignManager> getEntityClass() {
        return ForeignManager.class;
    }
}
